home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright Cornell University 1986. All rights are reserved.
-
- menu.c contains routines which create, maintain, and allow access to
- items in the Macintosh menus.
- */
-
- #include <em.h>
-
- #include <3270.h>
- #include <rcodes.h>
- #include <h19.h>
-
- #include <h19.h>
- #include <util.h>
- #include <macdefs.h>
- #include <resdefs.h>
- #include <cntldefs.h>
- #include <config.h>
- #include "menudefs.h"
-
- #include <net.h> /* merged TCP */
- #ifdef DUALTCP
- #endif
-
- #ifndef MACTCP
- #include <tcp.h>
- #include <tcpdefs.h>
- #endif
-
- extern char *malloc();
- extern Boolean alfilter();
- extern short modaldialog;
-
- char * keyswerr = "Can't update keypad switch in global configuration";
-
-
- #define OKB 1 /* OK button */
- #define CANB 2 /* cancel button */
-
- #define STOPICON 2 /* Apple Alert Icon */
-
- Handle iconh;
- Rect iconrect;
- Rect okrect;
-
- /* we need to get inside the ModalDialog event loop to guarantee cycles for tasks--hence, */
-
- pascal Boolean
- alfilter(dptr, devt, item)
- DialogPtr dptr;
- EventRecord * devt;
- int * item;
- {
- char thechar;
-
- if (devt->what == keyDown) {
- thechar = devt->message & 0xff;
- if (thechar == CR || thechar == 0x03) {
- *item = 1; /* default down on CR or Enter */
- return(TRUE);
- }
- if (devt->modifiers & cmdKey) {
- /* do Cancel */
- char thechar;
-
- thechar = devt->message & 0xff;
- switch (thechar) {
- case 'x': {
- DlgCut(dptr);
- *item = 0;
- return(TRUE);
- }
- case 'c': {
- DlgCopy(dptr);
- *item = 0;
- return(TRUE);
- }
- case 'v': {
- DlgPaste(dptr);
- *item = 0;
- return(TRUE);
- }
- case '.': {
- /* Command-. is a Cancel */
- *item = CANB;
- return(TRUE);
- }
- }
- }
- }
- else if (devt->what == activateEvt && devt->message == dptr) {
- GrafPtr oldport;
-
- if (myEvent.modifiers & activeFlag) {
- GetPort(&oldport);
- SetPort(dptr);
-
- if (okrect.top != okrect.bottom)
- buthilite(&okrect);
-
- SetPort(oldport);
- }
- }
- else if (devt->what == updateEvt && devt->message == dptr) {
- GrafPtr oldport;
-
- GetPort(&oldport);
- SetPort(dptr);
-
- if (okrect.top != okrect.bottom)
- buthilite(&okrect);
-
- SetPort(oldport);
- }
- else
- defaultevent(devt);
-
- #ifdef USETASK
- if (tk_cur != NULL) {
- /* if tasking is on, do a yield to avoid timeout */
- bkrd_service();
- }
- #endif
-
- return(FALSE);
- }
-
-
-
- pascal Boolean
- errorfilter(dptr, devt, item)
- DialogPtr dptr;
- EventRecord * devt;
- int * item;
- {
- char thechar;
- int type;
- Handle hitem;
- Rect rect;
-
- if (tk_cur != NULL) {
- /* if tasking is on, do a yield to avoid timeout */
- bkrd_service();
- }
- if (devt->what == keyDown) {
- thechar = devt->message & 0xff;
- if (thechar == CR || thechar == 0x03) {
- *item = 1; /* default down on CR or Enter */
- return(TRUE);
- }
- }
- else if (devt->what == activateEvt && devt->message == dptr) {
- GrafPtr oldport;
-
- if (myEvent.modifiers & activeFlag) {
- GetPort(&oldport);
- SetPort(dptr);
-
- GetDItem(dptr, OKB, &type, &hitem, &rect);
- buthilite(&rect);
- /* hilite "OK" key */
- PlotIcon(&iconrect, iconh);
-
- SetPort(oldport);
- }
- }
- else if (devt->what == updateEvt && devt->message == dptr) {
- GrafPtr oldport;
-
- GetPort(&oldport);
- SetPort(dptr);
-
- GetDItem(dptr, OKB, &type, &hitem, &rect);
- buthilite(&rect);
- /* hilite "OK" key */
- PlotIcon(&iconrect, iconh);
-
- SetPort(oldport);
- }
- else
- defaultevent(devt);
- return(FALSE);
- }
-
-
- short inerror;
-
- #define ERRTEXT 2
-
- error(string)
- char * string;
- {
- DialogPtr errdptr;
- int modalstate;
- int item_id;
- GrafPtr oport;
- int type; /* general purpose getditem vars */
- Handle hitem;
- Rect rect;
-
- if (inerror) {
- SysBeep(5);
- return(-1);
- }
-
- modalstate = modaldialog;
-
- if (chkbackground())
- return(-1);
-
- ctop(string);
-
- GetPort(&oport);
- inerror = TRUE;
-
- if ((errdptr = GetNewDialog(ALERROR, NULL, (WindowPtr) (-1))) == NULL) {
- ptoc(string);
- inerror = FALSE;
- return(-1);
- }
-
- GetDItem(errdptr, ERRTEXT, &type, &hitem, &rect);
- SetIText(hitem, string);
-
- emwdeactivate();
-
- centerwind(errdptr);
-
- modaldialog = TRUE;
- SetCursor(&arrow);
- showcursor();
- SetPort(errdptr);
-
- iconh = GetIcon(STOPICON);
- iconrect.top = 10;
- iconrect.left = 20;
- iconrect.bottom = 42;
- iconrect.right = 52;
- PlotIcon(&iconrect, iconh);
-
- GetDItem(errdptr, OKB, &type, &hitem, &rect);
- buthilite(&rect);
- /* hilite "OK" key */
-
- while (1) {
- ModalDialog((ProcPtr) errorfilter, &item_id);
- if (item_id == OKB)
- break;
- }
-
- SetPort(oport);
- DisposDialog(errdptr);
- ptoc(string);
- modaldialog = modalstate;
-
- inerror = FALSE;
- }
-
-
- stoperror(string)
- char * string;
- {
- error(string);
- }
-
- reserror()
- {
- if (ResError()) {
- error("Resource error");
- return(-1);
- }
- }
-
-
- /*
- * display text in a window; both are taken from resource file, with the
- * assumption the id number is the same for both
- */
-
- helpwindow(resid, font, fontsize)
- int resid;
- int font;
- int fontsize;
- {
- long length;
- Handle thetext;
-
- #ifdef USETEXTWINDOWS
- if (optkeydown() && keydp != NULL && keydp->textwindow != NULL) {
- /* dump into a text window */
- helptextwindow(resid);
- return;
- }
- #endif
-
- thetext = GetResource('TEXT', (short) resid);
- if (thetext == NULL)
- return(-1);
- HLock(thetext);
- length = GetHandleSize(thetext);
-
- fillwindow(resid, *thetext + 4, (long) (length - 4), font, fontsize, 0L);
- /* TEXT types have 4 bytes of length in them */
- HUnlock(thetext);
- }
-
-
- /* get a window with the specified id and fill with the text */
-
- fillwindow(resid, thetext, length, font, fontsize, waitfor)
- int resid;
- char * thetext;
- long length;
- int font;
- int fontsize;
- long waitfor; /*KS*/
- {
- Rect bounds;
- Rect nullrect;
- GrafPtr ohelpport;
- int modalstate;
- FontInfo finfo;
-
- if (chkbackground()) {
- return;
- }
- if (helpwind != NULL)
- fillwindclose();
-
- GetPort(&ohelpport);
-
- if ( (helpwind = GetNewWindow(resid, (Ptr) NULL, (WindowPtr) (-1)) ) == NULL)
- if ( (helpwind = GetNewWindow(1000 + fontsize, (Ptr) NULL, (WindowPtr) (-1)) ) == NULL)
- if ( (helpwind = GetNewWindow(1000, (Ptr) NULL, (WindowPtr) (-1)) ) == NULL)
- return(-1);
-
- if (keydp != NULL) {
- getcontext(keydp);
- emwdeactivate();
- }
- centerwind(helpwind);
-
- modalstate = modaldialog;
- modaldialog = TRUE;
- SetCursor(&arrow);
- showcursor();
- SetPort(helpwind);
-
- TextFont(font);
- TextSize(fontsize);
-
- GetFontInfo(&finfo);
-
- /* set up text edit record */
- bounds.top = 6;
- bounds.left = 6;
- bounds.bottom = thePort->portRect.bottom;
- bounds.right = thePort->portRect.right - 6;
- helptehand = TENew(&bounds, &bounds);
-
- (*helptehand)->fontAscent = finfo.ascent + finfo.leading;
- (*helptehand)->lineHeight = (*helptehand)->fontAscent + finfo.descent;
-
- (*helptehand)->txFont = font;
- (*helptehand)->txSize = fontsize;
- nullrect.top = nullrect.left = nullrect.bottom = nullrect.right = 0;
- /* TEUpdate(&nullrect, helptehand);
- incorporate the info */
- (*helptehand)->viewRect.bottom =
- bounds.top +
- ((thePort->portRect.bottom - bounds.top) / (*helptehand)->lineHeight )
- * (*helptehand)->lineHeight;
- /* round height of view rect to even bit multiple of font size */
-
- /* insert the text */
- TESetSelect( (long) 0, (long) (*helptehand)->teLength, helptehand);
- TEInsert(thetext, (long) length, helptehand);
-
- if (waitfor == -1) {
- /* exit immediately, app must do cleanup itself by calling fillwindclose() */
- SetPort(ohelpport);
- filltimeout = cticks + 500; /*KS*/
- modaldialog = modalstate;
- return(0);
- }
-
- filltimeout = cticks + waitfor; /*KS*/
-
- /* wait till a timeout or mouseDown event occurs to exit, unless a key is hit */
- while (TRUE) {
- EventRecord anevent;
-
- if (waitfor) {
- /* if a nonzero timeout has been given, check the time */
- if (cticks > filltimeout)
- break;
- }
- if (!GetNextEvent(mDownMask, &anevent)) {
- /* wait for a mousedown; don't take keystrokes off the queue */
- SystemTask(); /* keep this if/until we use WaitNextEvent */
- if (tk_cur != NULL) {
- /* if tasking is on, do a yield to avoid timeout */
- bkrd_service();
- }
- continue; /* KS */
- }
- SetPort(helpwind);
- /* do paging if text off bottom */
- if ( ((*helptehand)->lineHeight * (*helptehand)->nLines + (*helptehand)->destRect.top )
- > (*helptehand)->viewRect.bottom ) {
- /* do a scroll when bottom of text below bottom of window */
- TEScroll(0, - ((*helptehand)->viewRect.bottom - (*helptehand)->viewRect.top), helptehand);
- continue;
- }
- else
- break;
- }
-
- /* release */
- TEDispose(helptehand);
- DisposeWindow(helpwind);
- helpwind = NULL;
- modaldialog = modalstate;
- }
-
-
- /* dispose of the window created by fillwind */
-
- fillwindclose()
- {
- /* release */
- if (helpwind != NULL) {
- while (TRUE) {
- /* guarantee the copyright notice stays up long enough to be seen */
- if (cticks > filltimeout)
- break;
- }
- TEDispose(helptehand);
- DisposeWindow(helpwind);
- helpwind = NULL;
- }
- }
-
-
- /* display a copyright notice; app must clean up w/ fillwindclose() */
-
- copynotice()
- {
- extern char copyright[]; /* in appl/copy.c */
- EventRecord myEvent;
-
- /* eventavail will put these back on the queue, but not any event! */
- EventAvail(keyDownMask, &myEvent);
- EventAvail(keyDownMask, &myEvent);
- EventAvail(keyDownMask, &myEvent);
- /* these calls will prompt the MultiFinder to display our startup screen */
- fillwindow(COPYWINDOW, copyright, (long) strlen(copyright), geneva, 12, (long) -1);
- }
-
-
- /* do dialog to get connection type, terminal type, & IBM 7171 key
- mapping */
-
- #define NM_TITLE 3 /* title of dialog box, name and version */
-
- /* connection types */
- #define NM_CONN 5 /* conntype = the Connection Manager */
- #define NM_SERDA 6 /* = serial port a */
- #define NM_SERDB 7 /* = serial port b */
- #define NM_TCP 8 /* = TCP */
- #define NM_HOSTADDRTIT 9 /* = TCP */
- #define NM_CUTCP 17 /* = Cornell's TCP */
-
- #define NM_HOSTNAME 11 /* the hostname field */
- #define NM_HOSTADDR 12 /* the host address field */
- #define NM_IBMKEY 16 /* check box for serial IBM mode */
- #define NM_HELPBUT 18 /* help button */
-
- /* terminal types */
- #define NM_EMAUTOMATIC 19 /* try all of them--Telnet negotiation, serial vt100 */
- #define NM_VT100 20
- #define NM_3278 21
- #define NM_H19 22
- #define NM_VT102 23
- #define NM_VT220 24 /* unused */
-
-
- /* we need to get inside the ModalDialog event loop to guarantee cycles for tasks--hence, */
-
- Rect listrect; /* the rectangle user item in which list appears */
-
- #ifdef TCPSELECT
- short ipaddrvis = TRUE; /* the IP address has not been hidden */
- #endif
-
- pascal Boolean
- nmwindowfilter(dptr, devt, item)
- DialogPtr dptr;
- EventRecord * devt;
- int * item;
- {
- union {
- long l;
- Point p;
- } prevcell;
-
- bkrd_service();
- if (devt->what == keyDown) {
- if ((devt->message & 0xff) == CR || (devt->message & 0xff) == ETX) {
- devt->what = nullEvent; /* ignore the key */
- *item = OKB; /* default down */
- return((Boolean) TRUE);
- }
- if (devt->modifiers & cmdKey) {
- /* do Cancel */
- char thechar;
-
- thechar = devt->message & 0xff;
- switch (thechar) {
- case 'x': {
- DlgCut(dptr);
- *item = 0;
- return(TRUE);
- }
- case 'c': {
- DlgCopy(dptr);
- *item = 0;
- return(TRUE);
- }
- case 'v': {
- DlgPaste(dptr);
- *item = 0;
- return(TRUE);
- }
- case '.': {
- /* Command-. is a Cancel */
- *item = CANB;
- return(TRUE);
- }
- }
- }
- #ifdef TCPSELECT
- /* it's a bitch to make tcp selections turn on and off intelligently... */
- if ((devt->message & 0xff) == TAB) {
- if (!ipaddrvis) {
- devt->what = nullEvent; /* ignore the key */
- return((Boolean) FALSE);
- }
-
- }
- #endif
- }
- else if (devt->what == activateEvt && devt->message == dptr) {
- GrafPtr oldport;
-
- if (myEvent.modifiers & activeFlag) {
- GetPort(&oldport);
- SetPort(dptr);
-
- buthilite(&okrect);
-
- SetPort(oldport);
- }
- }
- else if (devt->what == updateEvt && devt->message == dptr) {
- GrafPtr oldport;
-
- GetPort(&oldport);
- SetPort(dptr);
-
- /* BeginUpdate(dptr); */
- buthilite(&okrect);;
- /* FrameRect(&listrect);
- make a box around the list */
-
- /* EndUpdate(dptr); */
- SetPort(oldport);
- }
- else
- defaultevent(devt);
- return((Boolean) FALSE);
- }
-
-
-
- namewindow()
- {
- DialogPtr nmdptr;
- Handle hname; /* dialog hostname handle */
- Handle haddr; /* dialog hostaddress handle */
- Handle hibmkey; /* dialog hostaddress handle */
- Handle haddrtit; /* dialog hostaddress title */
-
- Str255 strhostname; /* name of host as string */
- Str255 strhostaddr; /* address of host as string */
- Str255 strhostaddrtit; /* address of host title */
- Handle title;
- Handle hmyaddr; /* dialog hostaddress handle */
- Handle hgateaddr; /* dialog hostaddress handle */
- Handle hok; /* ok button */
-
- GrafPtr oport;
- int item_id; /* item that was touched */
- int len;
- short count;
- int type; /* general purpose getditem vars */
- Handle hitem;
- Rect rect;
-
- short termindex;
- char odisableterm[TERMTYPEMAX];
- short tempconntype;
- short oibmkey;
- short onewconf;
- short nmcutcp; /* Cornell TCP is selected if TRUE */
- short firstterm = FALSE;
-
- /* else launched direct from application or no host name exists, do the dialog */
- if (chkbackground())
- return(-1);
-
- GetPort(&oport);
- emwdeactivate();
-
- if ((nmdptr = GetNewDialog(DNEWWIND, NULL, (WindowPtr) (-1))) == NULL)
- return(-1);
-
- centerwind(nmdptr);
-
- modaldialog = TRUE;
- SetCursor(&arrow);
-
- showcursor();
-
- SetPort(nmdptr);
-
- /* save the state of things we modify in case we Cancel */
- for (count = 0; count < TERMTYPECOUNT; count++) {
- odisableterm[count] = emdp->disableterm[count];
- }
- tempconntype = emdp->conntype;
- oibmkey = emdp->ibm_keymode;
-
-
- GetDItem(nmdptr, OKB, &type, &hitem, &okrect);
- buthilite(&okrect);
-
- /* window name */
- GetDItem(nmdptr, NM_HOSTNAME, &type, &hname, &rect);
- if (emdp->hhostname) {
- /* paste the name in */
- HLock(emdp->hhostname);
- SetIText(hname, *emdp->hhostname);
- HUnlock(emdp->hhostname);
- }
-
- /* IP host address if any */
- GetDItem(nmdptr, NM_HOSTADDR, &type, &haddr, &rect);
- if (emdp->hlasthost) {
- /* paste the address in */
- HLock(emdp->hlasthost);
- ctop(*emdp->hlasthost);
- SetIText(haddr, *emdp->hlasthost);
- ptoc(*emdp->hlasthost);
- HUnlock(emdp->hlasthost);
- }
-
- GetDItem(nmdptr, NM_HOSTADDRTIT, &type, &haddrtit, &rect);
-
- /* ibm key interpretation mode for ASCII 7171 access */
- GetDItem(nmdptr, NM_IBMKEY, &type, &hibmkey, &rect);
- if (emdp->ibm_keymode)
- SetCtlValue(hibmkey, 1);
-
- /* disable the Conn Mgr option until it works */
- GetDItem(nmdptr, NM_CONN, &type, &hitem, &rect);
- HiliteControl(hitem, 255);
-
- /* Select the Name Text "Untitled" or whatever */
- SelIText(nmdptr, NM_HOSTNAME, 0, 1000);
-
-
- #ifdef DUALTCP
- /* show the current connection type */
-
- if (emdp->conntype == CONN_MACTCP) {
- /* show MacTCP enabled */
- GetDItem(nmdptr, NM_CUTCP, &type, &hitem, &rect);
- SetCtlValue(hitem, 1);
- nmcutcp = FALSE;
- }
- else {
- if (emdp->conntype == CONN_CUTCP) {
- /* fake it */
- tempconntype = CONN_MACTCP;
- }
- nmcutcp = TRUE;
- }
- #else
- if (emdp->conntype == CONN_CUTCP) {
- /* force it */
- emdp->conntype = CONN_MACTCP;
- tempconntype = CONN_MACTCP;
- }
- nmcutcp = FALSE;
-
- /* hide MacTCP control, since we always use macTCP */
- GetDItem(nmdptr, NM_CUTCP, &type, &hitem, &rect);
- HideControl(hitem);
- GetDItem(nmdptr, NM_TCP, &type, &hitem, &rect);
- SetCTitle(hitem, "\PMacTCP Telnet");
-
- #endif
-
- /* show the current connection type */
- if (emdp->conntype == CONN_MACTCP || emdp->conntype == CONN_CUTCP) {
- GetDItem(nmdptr, NM_TCP, &type, &hitem, &rect);
- SetCtlValue(hitem, 1);
- nmsettcp(nmdptr, TRUE);
- }
- else if (emdp->conntype == CONN_SERD) {
- GetDItem(nmdptr, emdp->usebport ? NM_SERDB : NM_SERDA, &type, &hitem, &rect);
- SetCtlValue(hitem, 1);
- nmsettcp(nmdptr, FALSE);
- }
- else if (emdp->conntype == CONN_COMMMGR) {
- GetDItem(nmdptr, NM_CONN, &type, &hitem, &rect);
- SetCtlValue(hitem, 1);
- nmsettcp(nmdptr, FALSE);
- }
-
- /* show the current terminal types; auto will have ALL FALSE */
- /* the logic could be a little simpler, but the original interface allowed
- selecting arbitrary lists of enabled terminals rather than
- auto or just one... */
-
- for (count = 0, termindex = NM_VT100; count < TERMTYPECOUNT;
- count++, termindex++) {
-
- if (emdp->disableterm[count]) {
- if (firstterm)
- /* we've found one enabled & one disabled, not auto */
- break;
- else
- /* try to find an enabled terminal */
- continue;
- }
- else {
- if (!firstterm) {
- /* remember the first terminal we find enabled in case
- they aren't ALL enabled... */
- firstterm = termindex;
- if (count == (TERMTYPECOUNT - 1) ) {
- /* last terminal in the list, make sure count < TERMTYPECOUNT */
- break;
- }
- }
- }
- }
- if (count >= TERMTYPECOUNT) {
- /* all or none were selected, select the terminal type automatically */
- GetDItem(nmdptr, NM_EMAUTOMATIC, &type, &hitem, &rect);
- }
- else {
- GetDItem(nmdptr, firstterm, &type, &hitem, &rect);
- }
- /* set the terminal type radio button on */
- SetCtlValue(hitem, 1);
-
- TEFromScrap();
-
- while (1)
- {
- ModalDialog((ProcPtr) nmwindowfilter, &item_id);
- termindex = item_id - NM_VT100;
- switch (item_id)
- {
- case OKB: {
- for (count = 0; count < TERMTYPECOUNT; count++) {
- if (!emdp->disableterm[count])
- break;
- }
- if (count == TERMTYPECOUNT) {
- error("Sorry, but you must enable at least one terminal type!");
- buthilite(&okrect);
- break;
- }
-
- GetIText(hname, &strhostname);
-
- if (tempconntype == CONN_MACTCP) {
- /* discriminate between the TCPs */
- if (nmcutcp)
- emdp->conntype = CONN_CUTCP;
- else
- emdp->conntype = CONN_MACTCP;
- }
- else
- emdp->conntype = tempconntype;
-
- if (macipopen
- && tempconntype != CONN_MACTCP
- && emdp->tcp_stream)
- {
- /* MacTCP was open for this window */
- if (emdp->connopen) {
- error("You need to close the open session before switching from MacTCP");
- break;
- }
- else {
- /* release MacTCP memory */
- tcp_release(emdp);
- tcpmemoryreclaim(emdp);
- }
- }
-
- /* check to see whether the TCP package used should change */
- if (macipopen) {
- if (emdp->conntype == CONN_CUTCP) {
- error("Opening session using MacTCP, which is already running");
- emdp->conntype = CONN_MACTCP;
- }
- }
- else if (cutcpopen) {
- if (emdp->conntype == CONN_MACTCP) {
- error("Opening session using Cornell TCP, which is already running");
- emdp->conntype = CONN_CUTCP;
- }
- }
-
- if (emdp->conntype == CONN_MACTCP
- || emdp->conntype == CONN_CUTCP) {
- /* use the host name entry */
- GetIText(haddr, &strhostaddr);
- len = strhostaddr.length + 1;
- ptoc(&strhostaddr);
-
- GetIText(haddrtit, &strhostaddrtit);
- SetIText(haddrtit, "\PResolving...");
-
- if (resolve_name(&strhostaddr, &emdp->fhost)) {
- /* error occurred, the title to "Host address" */
- SetIText(haddrtit, &strhostaddrtit);
- break;
- }
-
- if (emdp->hlasthost) {
- DisposHandle(emdp->hlasthost);
- emdp->hlasthost = NULL;
- }
- PtrToHand(&strhostaddr, &emdp->hlasthost, (long) len);
- /* save address as c string in emdp->hlasthost */
-
- }
-
- len = strhostname.length + 1;
- if (emdp->hhostname) {
- DisposHandle(emdp->hhostname);
- emdp->hhostname = NULL;
- }
- PtrToHand(&strhostname, &emdp->hhostname, (long) len);
- /* save name as pascal string in emdp->hhostname */
- setappfilename();
- /* reset the default document file name */
-
- if (emdp->emwindow) {
- /* update the window title if a window exists */
- HLock(emdp->hhostname);
- windowtitle(emdp, *emdp->hhostname);
- HUnlock(emdp->hhostname);
- windmenutitle(emdp);
- }
- ZeroScrap();
- TEToScrap();
- /* copy the TE scrap to the Scrap */
-
- DisposDialog(nmdptr);
- SetPort(oport);
- modaldialog = FALSE;
-
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
- return(0);
- }
- case CANB: {
- /* restore the old settings */
- for (count = 0; count < TERMTYPECOUNT; count++) {
- emdp->disableterm[count] = odisableterm[count];
- }
- emdp->ibm_keymode = oibmkey;
- emdp->confchanged = FALSE;
- emdp->newconf = onewconf;
-
- ZeroScrap();
- TEToScrap();
- /* copy the TE scrap to the Scrap */
-
- DisposDialog(nmdptr);
- SetPort(oport);
- modaldialog = FALSE;
-
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
- return(-1);
- }
- case NM_HOSTADDR: {
- emdp->confchanged = TRUE;
- break;
- }
- case NM_HOSTNAME: {
- emdp->confchanged = TRUE;
- emdp->newconf = TRUE;
- break;
- }
- /* connection types -- 4 radio buttons */
- case NM_CONN: {
- nmdialbutset(nmdptr, item_id);
- nmsettcp(nmdptr, FALSE);
- tempconntype = CONN_COMMMGR;
- break;
- }
- case NM_SERDA: {
- nmdialbutset(nmdptr, item_id);
- nmsettcp(nmdptr, FALSE);
- tempconntype = CONN_SERD;
- emdp->usebport = FALSE;
- break;
- }
- case NM_SERDB: {
- nmdialbutset(nmdptr, item_id);
- nmsettcp(nmdptr, FALSE);
- tempconntype = CONN_SERD;
- emdp->usebport = TRUE;
- break;
- }
- case NM_TCP: {
- /* select TCP */
- nmdialbutset(nmdptr, item_id);
- nmsettcp(nmdptr, TRUE);
- tempconntype = CONN_MACTCP;
- break;
- }
- #ifdef DUALTCP
- case NM_CUTCP: {
- /* switch between MacTCP & cornell */
- /* you can't change transport horses in midstream */
- if (nmcutcp) {
- nmcutcp = FALSE;
- }
- else
- nmcutcp = TRUE;
-
- GetDItem(nmdptr, NM_CUTCP, &type, &hitem, &rect);
- SetCtlValue(hitem, nmcutcp ? 0 : 1);
- break;
- }
- #endif
- /* terminal types, 3 check boxes */
- case NM_VT100:
- case NM_VT102:
- case NM_3278:
- case NM_H19:
- case NM_EMAUTOMATIC:
- {
- nmtermbutset(nmdptr, item_id);
- break;
- }
- case NM_IBMKEY: {
- /* UNUSED--now set in the Control Window dialog */
-
- emdp->ibm_keymode = !emdp->ibm_keymode;
- emdp->confchanged = TRUE;
- SetCtlValue(hibmkey, emdp->ibm_keymode ? 1 : 0);
- break;
- }
- case NM_HELPBUT: {
- helpwindow(TEXTLOGON, geneva, 9);
- modaldialog = TRUE;
- break;
- }
- default: {
- break;
- }
- }
- }
- }
-
-
- /* set TCP items on or off */
-
- nmsettcp(nmdptr, state)
- DialogPtr nmdptr;
- int state;
- {
- Handle hitem;
- short type;
- Rect rect;
-
- #ifdef TCPSELECT
- if (state == ipaddrvis) {
- /* same state as before, ignore */
- return;
- }
- else {
- ipaddrvis = state;
-
- if (ipaddrvis) {
- GetDItem(nmdptr, NM_HOSTADDR, &type, &hitem, &rect);
- SetDItem(nmdptr, NM_HOSTADDR, editText, hitem, &rect);
-
- GetDItem(nmdptr, NM_HOSTADDRTIT, &type, &hitem, &rect);
- SetDItem(nmdptr, NM_HOSTADDRTIT, statText, hitem, &rect);
-
- /* switch to the address editing field */
- SelIText(nmdptr, NM_HOSTNAME, 0, 0);
- SelIText(nmdptr, NM_HOSTADDR, 0, 1000);
- }
- else {
- if (((DialogPeek) nmdptr)->editField == NM_HOSTADDR - 1) {
- /* switch to the name editing field if Address is the current field */
- SelIText(nmdptr, NM_HOSTADDR, 0, 0);
- SelIText(nmdptr, NM_HOSTNAME, 0, 1000);
- }
- GetDItem(nmdptr, NM_HOSTADDR, &type, &hitem, &rect);
- SetDItem(nmdptr, NM_HOSTADDR, editText, hitem, &rect);
- /* + itemDisable, if only Dialog Manager did something useful... */
- GetDItem(nmdptr, NM_HOSTADDRTIT, &type, &hitem, &rect);
- SetDItem(nmdptr, NM_HOSTADDRTIT, statText + itemDisable, hitem, &rect);
- }
- }
- #else
- /* doesn't actually disable the thing anyway... lord the dialog manager is
- useless!
- GetDItem(nmdptr, NM_HOSTADDR, &type, &hitem, &rect);
- SetDItem(nmdptr, NM_HOSTADDR, type + state, hitem, &rect);
- */
-
- GetDItem(nmdptr, NM_HOSTADDRTIT, &type, &hitem, &rect);
- SetDItem(nmdptr, NM_HOSTADDRTIT, type + state, hitem, &rect);
-
- #ifdef DUALTCP
- GetDItem(nmdptr, NM_CUTCP, &type, &hitem, &rect);
- HiliteControl(hitem, state ? 0 : 255);
- #endif
- #endif
- }
-
- /* set the button selected and reset the others */
-
- nmdialbutset(dlog, itemid)
- DialogPtr dlog;
- short itemid;
- {
- short type;
- Rect rect;
- Handle hitem;
-
- emdp->confchanged = TRUE;
-
- GetDItem(dlog, NM_CONN, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == NM_CONN ? 1 : 0);
- GetDItem(dlog, NM_SERDA, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == NM_SERDA ? 1 : 0);
- GetDItem(dlog, NM_SERDB, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == NM_SERDB ? 1 : 0);
- GetDItem(dlog, NM_TCP, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == NM_TCP ? 1 : 0);
- }
-
-
- /* set the button selected and reset the others; */
-
- nmtermbutset(dlog, itemid)
- DialogPtr dlog;
- short itemid;
- {
- short type;
- Rect rect;
- Handle hitem;
-
- emdp->confchanged = TRUE;
-
- /* set only one radio button for emulation: auto, vt100, 3270, h19 */
-
- GetDItem(dlog, NM_EMAUTOMATIC, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == NM_EMAUTOMATIC ? 1 : 0);
-
- GetDItem(dlog, NM_VT100, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == NM_VT100 ? 1 : 0);
-
- GetDItem(dlog, NM_VT102, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == NM_VT102 ? 1 : 0);
-
- GetDItem(dlog, NM_3278, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == NM_3278 ? 1 : 0);
-
- GetDItem(dlog, NM_H19, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == NM_H19 ? 1 : 0);
-
- /* set the disableterm array accordingly */
- if (itemid == NM_EMAUTOMATIC) {
- /* enable all the terminals */
- emdp->disableterm[TERM_VT100] = FALSE;
- emdp->disableterm[TERM_VT102] = FALSE;
- emdp->disableterm[TERM_VT220] = FALSE;
- emdp->disableterm[TERM_3270] = FALSE;
- emdp->disableterm[TERM_H19] = FALSE;
- }
- else {
- /* enable only one terminal */
- emdp->disableterm[TERM_VT100] = (itemid == NM_VT100 ? FALSE : TRUE);
- emdp->disableterm[TERM_VT102] = (itemid == NM_VT102 ? FALSE : TRUE);
- emdp->disableterm[TERM_3270] = (itemid == NM_3278 ? FALSE : TRUE);
- emdp->disableterm[TERM_H19] = (itemid == NM_H19 ? FALSE : TRUE);
- }
- }
-
-
- /* perform a dialog to set the color map */
-
- #define CM_OK 1
- #define CM_CANCEL 2
- #define CM_COLOR 3 /* "Color Map On" Title/Button */
- #define CM_BAR 4
- #define CM_CBASE 5 /* 8 * 2 check boxes filled with color */
- #define CM_CEND 21 /* 8 * 2 check boxes filled with color */
- #define CM_STROFF 26 /* string descriptions */
- #define CM_BOX 34 /* where to draw strings */
- #define CM_SESSIONNAME 35
-
- char * setcolortext[] = {
- /* ASCII attribute types */
- "Normal",
- "Reverse",
- "Bold",
- "Bold Reverse",
- "Blink",
- "Blink Reverse",
- "Blink Bold",
- "Blink Bold Reverse",
-
- /* IBM field types */
- "Normal",
- "Sense",
- "Bold",
- "Invisible",
- "Protected",
- "Protected Sense",
- "Protected Bold",
- "Protected Invisible"
- };
- #define CM_STROFFMAX 15 /* longest string description, happens to be last */
-
-
- setcolormap()
- {
- DialogPtr cmdial;
- short item_id;
- short type;
- Rect rect;
- Rect boxrect;
- Handle hitem;
- /* general purpose GetDItem vars */
- GrafPtr oport;
- short count;
- short control;
- short colorindex;
- struct ibmcolormap backupmap;
- Point point;
- Handle ditlh;
- RGBColor forecolor;
- RGBColor backcolor;
- char string[255];
- char spaces[255];
- short ocolor;
- short ofont;
- short osize;
- short incount;
- char windtit[256]; /* temp for window title */
-
- if (chkbackground())
- return;
-
- GetPort(&oport);
- /* a 'dctb' resource exists, so a Color window will be allocated ... */
- if ((cmdial = GetNewDialog(DSETCOLORMAP, (Ptr) NULL, (WindowPtr) (-1))) == NULL)
- return(-1);
-
- getcontext(keydp);
- emwdeactivate();
- overwind(cmdial); /* place over current window rather than
- default screen to represent the colormap situation accurately */
-
- SetCursor(&arrow);
- showcursor();
- SetPort(cmdial);
-
- modaldialog = TRUE;
-
- GetDItem(cmdial, CM_BOX, &type, &hitem, &boxrect);
- /* get box for drawing examples */
-
- GetDItem(cmdial, CM_OK, &type, &hitem, &okrect);
- buthilite(&okrect);
- /* hilite "OK" key */
-
- GetDItem(cmdial, CM_SESSIONNAME, &type, &hitem, &rect);
- GetWTitle(emdp->emwindow, &windtit[0]);
- SetIText(hitem, &windtit[0]);
- /* put the session name in the window */
-
- GetDItem(cmdial, CM_COLOR, &type, &hitem, &rect);
- SetCtlValue(hitem, keydp->color ? 1 : 0);
- /* set "Color Map On" button */
-
- TextMode(srcCopy); /* obliterate when redrawing */
- ofont = ((GrafPtr) cmdial)->txFont;
- osize = ((GrafPtr) cmdial)->txSize;
-
- /* make a pascal space string the same size as the text items */
- spaces[0] = strlen(setcolortext[CM_STROFFMAX]);
- for (count = 1; count <= spaces[0]; count++)
- spaces[count] = ' ';
-
- /* title the controls */
- for (count = 0; count < 8; count++) {
- int ibmoffset;
-
- ibmoffset = keydp->ibm_mode ? 8 : 0;
- GetDItem(cmdial, count + CM_STROFF, &type, &hitem, &rect);
-
- sprintf(&string[0], "%s", setcolortext[count + ibmoffset]);
- ctop(&string[0]);
-
- /* append spaces to the items to even out their lengths */
- for (incount = string[0] + 1; incount <= spaces[0]; incount++) {
- string[incount] = ' ';
- }
- string[0] = spaces[0];
-
- SetIText(hitem, &string[0]);
- }
-
- /* save the current array and draw the example text */
- GetForeColor(&forecolor);
- GetBackColor(&backcolor);
- backupmap = keydp->ibmcolormap;
- ocolor = keydp->color;
-
- TextFont(monaco);
- TextSize(9);
-
- /* the second check box of each pair has text describing the function...
- draw it in WYSIWYG color */
-
- for (control = CM_CBASE, count = colorindex = 0;
- control < CM_CEND;
- count++, control++, colorindex += 2) {
-
- GetDItem(cmdial, control++, &type, &hitem, &rect);
- RGBForeColor(&forecolor);
- FrameRect(&rect);
- InsetRect(&rect, 1, 1);
- RGBForeColor(&keydp->ibmcolormap.colors[colorindex]);
- PaintRect(&rect);
-
- GetDItem(cmdial, control, &type, &hitem, &rect);
- RGBForeColor(&forecolor);
- FrameRect(&rect);
- InsetRect(&rect, 1, 1);
- RGBForeColor(&keydp->ibmcolormap.colors[colorindex + 1]);
- PaintRect(&rect);
-
- /* draw an example if not INVIS */
- RGBForeColor(&keydp->ibmcolormap.colors[colorindex]);
- RGBBackColor(&keydp->ibmcolormap.colors[colorindex + 1]);
- MoveTo(boxrect.left, rect.top + 10);
- if (keydp->ibm_mode && (colorindex == 6 || colorindex == 14))
- /* WYSIWYG, don't draw invis text */
- DrawString(&spaces[0]);
- else {
- GetDItem(cmdial, count + CM_STROFF, &type, &hitem, &rect);
- GetIText(hitem, &string[0]);
- DrawString(&string[0]);
- }
- }
- RGBForeColor(&forecolor);
- RGBBackColor(&backcolor);
- TextFont(ofont);
- TextSize(osize);
-
- while (TRUE) {
- ModalDialog((ProcPtr) alfilter, &item_id);
- switch (item_id) {
- case CM_CANCEL: {
- /* restore the old settings */
- keydp->ibmcolormap = backupmap;
- keydp->color = ocolor;
- /* fall through */
- }
- case CM_OK: {
- Rect paintrect; /* emulator area on screen */
-
- if (keydp->color)
- keydp->realattr = DSPMOD;
- else
- keydp->realattr = DSPD;
-
- SetPort(keywindow);
-
- paintrect.top = -5;
- paintrect.left = -3;
- paintrect.bottom = keywindow->portRect.bottom;
- paintrect.right = keydp->h19right - 7;
-
- if (!keydp->color)
- EraseRect(&paintrect);
-
- InvalRect(&paintrect);
- DisposDialog(cmdial);
- SetPort(oport);
- modaldialog = FALSE;
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
-
- if (item_id == CM_CANCEL)
- return(-1);
- else
- return(0);
- }
- case CM_COLOR: {
- keydp->color = !keydp->color;
- GetDItem(cmdial, CM_COLOR, &type, &hitem, &rect);
- SetCtlValue(hitem, keydp->color ? 1 : 0);
- break;
- }
- default: {
- if (item_id >= CM_CBASE && item_id < CM_CEND) {
- /* do a color picker dialog for the item */
- colorindex = item_id - CM_CBASE;
-
- /* place the picker over the dialog */
- point.v = ((GrafPtr) cmdial)->portRect.top + 5;
- point.h = ((GrafPtr) cmdial)->portRect.left + 5;
- LocalToGlobal(&point);
-
- GetDItem(cmdial, ((colorindex / 2) + CM_STROFF),
- &type, &hitem, &rect);
- GetIText(hitem, &string[0]);
-
- /* bogus getcolor call pushes getcolor selector #9 on stack */
- getcolor(pass(point), (StringPtr) &string[0],
- &keydp->ibmcolormap.colors[colorindex],
- &keydp->ibmcolormap.colors[colorindex],
- 9);
- buthilite(&okrect);
-
- /* redraw the example text */
- GetForeColor(&forecolor);
- GetBackColor(&backcolor);
- TextFont(monaco);
- TextSize(9);
-
- for (control = CM_CBASE, count = colorindex = 0;
- control < CM_CEND;
- count++, control++, colorindex += 2) {
-
- GetDItem(cmdial, control++, &type, &hitem, &rect);
- RGBForeColor(&forecolor);
- FrameRect(&rect);
- InsetRect(&rect, 1, 1);
- RGBForeColor(&keydp->ibmcolormap.colors[colorindex]);
- PaintRect(&rect);
-
- GetDItem(cmdial, control, &type, &hitem, &rect);
- RGBForeColor(&forecolor);
- FrameRect(&rect);
- InsetRect(&rect, 1, 1);
- RGBForeColor(&keydp->ibmcolormap.colors[colorindex + 1]);
- PaintRect(&rect);
-
- /* draw an example if not INVIS */
- RGBForeColor(&keydp->ibmcolormap.colors[colorindex]);
- RGBBackColor(&keydp->ibmcolormap.colors[colorindex + 1]);
- MoveTo(boxrect.left, rect.top + 10);
- if (keydp->ibm_mode && (colorindex == 6 || colorindex == 14))
- /* WYSIWYG, don't draw invis text */
- DrawString(&spaces[0]);
- else {
- GetDItem(cmdial, count + CM_STROFF, &type, &hitem, &rect);
- GetIText(hitem, &string[0]);
- DrawString(&string[0]);
- }
- }
- RGBForeColor(&forecolor);
- RGBBackColor(&backcolor);
- TextFont(ofont);
- TextSize(osize);
- }
- break;
- }
- }
- }
- }
-
-
- /* perform a dialog to do Window Configuration for session items */
-
- #define WC_OK 1
- #define WC_CANCEL 2
- #define WC_HELP 3 /* type #s must correspond to this list */
- #define WC_SESSIONNAME 4
-
- #define WC_TITLE 3 /* 12 types are allocated in the dialog */
-
- #define WC_MFSHRINK 7
- #define WC_CLOSE 8
- #define WC_BLOCK 9
- #define WC_BLINK 10
-
- #define WC_EDITDOWNWRAP 13
- #define WC_EDITUPWRAP 14
-
-
- setwindconf()
- {
- DialogPtr wcdial;
- short item_id;
- short type;
- Rect rect;
- Handle hitem;
- /* general purpose GetDItem vars */
- GrafPtr oport;
- short count;
- short termindex;
- char windtit[256]; /* temp for window title */
-
- /* vars we work on */
- short autoshrink;
- short disposeonclose;
- short blockcurs;
- short changecurs;
- short editupwrap;
- short editdownwrap;
-
- if (chkbackground())
- return(-1);
-
- GetPort(&oport);
- if ((wcdial = GetNewDialog(DWINDCONFIG, (Ptr) NULL, (WindowPtr) (-1))) == NULL)
- return(-1);
-
- getcontext(keydp);
- emwdeactivate();
-
- SetPort(wcdial);
- centerwind(wcdial);
-
- SetCursor(&arrow);
- showcursor();
-
- modaldialog = TRUE;
-
- GetDItem(wcdial, WC_OK, &type, &hitem, &okrect);
- buthilite(&okrect);
- /* hilite "OK" key */
-
- GetDItem(wcdial, WC_SESSIONNAME, &type, &hitem, &rect);
- GetWTitle(emdp->emwindow, &windtit[0]);
- SetIText(hitem, &windtit[0]);
- /* put the session name in the window */
-
- /* get current settings */
- autoshrink = emdp->autoshrink;
- disposeonclose = emdp->disposeonclose;
- blockcurs = emdp->blockcurs;
- changecurs = emdp->changecurs;
- editupwrap = emdp->editupwrap;
- editdownwrap = emdp->editdownwrap;
-
- /* set the controls to reflect the settings */
- GetDItem(wcdial, WC_MFSHRINK, &type, &hitem, &rect);
- SetCtlValue(hitem, autoshrink ? 1 : 0);
- GetDItem(wcdial, WC_CLOSE, &type, &hitem, &rect);
- SetCtlValue(hitem, disposeonclose ? 1 : 0);
- GetDItem(wcdial, WC_BLOCK, &type, &hitem, &rect);
- SetCtlValue(hitem, blockcurs ? 1 : 0);
- GetDItem(wcdial, WC_BLINK, &type, &hitem, &rect);
- SetCtlValue(hitem, changecurs ? 1 : 0);
-
- GetDItem(wcdial, WC_EDITUPWRAP, &type, &hitem, &rect);
- SetCtlValue(hitem, editupwrap ? 1 : 0);
- GetDItem(wcdial, WC_EDITDOWNWRAP, &type, &hitem, &rect);
- SetCtlValue(hitem, editdownwrap ? 1 : 0);
-
- while (TRUE) {
- ModalDialog((ProcPtr) alfilter, &item_id);
- termindex = item_id - 3;
- switch (item_id) {
- case WC_OK: {
- if (blockcurs != emdp->blockcurs) {
- SetPort(emdp->emwindow);
- newcursor();
- SetPort(wcdial);
- }
-
- /* update the settings */
- emdp->autoshrink = autoshrink;
- emdp->disposeonclose = disposeonclose;
- emdp->blockcurs = blockcurs;
- emdp->changecurs = changecurs;
- emdp->editupwrap = editupwrap;
- emdp->editdownwrap = editdownwrap;
-
- emdp->confchanged = TRUE;
-
- }
- case WC_CANCEL: {
- DisposDialog(wcdial);
- SetPort(oport);
- modaldialog = FALSE;
-
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
- if (item_id == WC_CANCEL)
- return(-1);
- return(0);
- }
- case WC_HELP: {
- helpwindow(TEXTWINDDLOG, geneva, 9);
- buthilite(&okrect);
- break;
- }
- case WC_MFSHRINK: {
- autoshrink = !autoshrink;
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, autoshrink ? 1 : 0);
- break;
- }
- case WC_CLOSE: {
- disposeonclose = !disposeonclose;
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, disposeonclose ? 1 : 0);
- break;
- }
- case WC_BLOCK: {
- blockcurs = !blockcurs;
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, blockcurs ? 1 : 0);
- break;
- }
- case WC_BLINK: {
- changecurs = !changecurs;
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, changecurs ? 1 : 0);
- break;
- }
- case WC_EDITUPWRAP: {
- editupwrap = !editupwrap;
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, editupwrap ? 1 : 0);
- break;
- }
- case WC_EDITDOWNWRAP: {
- editdownwrap = !editdownwrap;
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, editdownwrap ? 1 : 0);
- break;
- }
- default: {
- break;
- }
- }
- }
- }
-
-
- #define WC_EMTITLE 7 /* emulator name with 4 check boxes */
-
- /* skip line for bar */
- #define WC_EM1 8
- #define WC_EM2 9
- #define WC_EM3 10
- #define WC_EM4 11
- #define WC_EM5 12
- #define WC_EM6 13
- #define WC_EM7 14
-
- #define WC_VTROWS 17
- #define WC_VTCOLS 18
-
-
- /* configure emulator-specific session parameters; uses same basic fields
- as the setwindconf() dialog */
-
- setvtconf()
- {
- DialogPtr wcdial;
- short item_id;
- short type;
- Rect rect;
- Handle hitem;
- /* general purpose GetDItem vars */
- GrafPtr oport;
- short count;
- short termindex;
- char windtit[256]; /* temp for window title */
-
- /* ASCII things */
- short escmap;
- short ba_bs;
- short crtonl;
- short emwrap;
- short curseekmode;
- short ibm_keymode;
- short vtjumpscroll;
-
- short linecount;
- short linelength;
-
- if (chkbackground())
- return(-1);
-
- GetPort(&oport);
- if ((wcdial = GetNewDialog(DVTCONFIG, (Ptr) NULL, (WindowPtr) (-1))) == NULL)
- return(-1);
-
- getcontext(keydp);
- emwdeactivate();
-
- SetPort(wcdial);
- centerwind(wcdial);
-
- SetCursor(&arrow);
- showcursor();
-
- modaldialog = TRUE;
-
- GetDItem(wcdial, WC_OK, &type, &hitem, &okrect);
- buthilite(&okrect);
- /* hilite "OK" key */
-
- GetDItem(wcdial, WC_SESSIONNAME, &type, &hitem, &rect);
- GetWTitle(emdp->emwindow, &windtit[0]);
- SetIText(hitem, &windtit[0]);
- /* put the session name in the window */
-
- GetDItem(wcdial, WC_EMTITLE, &type, &hitem, &rect);
- SetIText(hitem, "\P ASCII emulator configuration");
-
- if (emdp->ibm_keymode) {
- /* hide all the ASCII-related controls */
- GetDItem(wcdial, WC_EM6, &type, &hitem, &rect);
- HideControl(hitem);
-
- GetDItem(wcdial, WC_EM7, &type, &hitem, &rect);
- HideControl(hitem);
- }
- GetDItem(wcdial, WC_EM1, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Use IBM menus and key mapping");
- SetCtlValue(hitem, emdp->ibm_keymode ? 1 : 0);
-
- GetDItem(wcdial, WC_EM2, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Map ` to Escape");
- SetCtlValue(hitem, emdp->escmap ? 1 : 0);
-
- GetDItem(wcdial, WC_EM3, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Map Backspace to Delete");
- SetCtlValue(hitem, emdp->ba_bs ? 0 : 1);
-
- GetDItem(wcdial, WC_EM4, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Map Return to Newline");
- SetCtlValue(hitem, emdp->crtonl ? 1 : 0);
-
- GetDItem(wcdial, WC_EM5, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Wrap text when line overflows");
- SetCtlValue(hitem, emdp->wrap_around ? 1 : 0);
-
- GetDItem(wcdial, WC_EM6, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Send vi commands to position cursor");
- SetCtlValue(hitem, emdp->curseekmode ? 1 : 0);
-
- GetDItem(wcdial, WC_EM7, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Use VT100 jump scrolling mode");
- SetCtlValue(hitem, emdp->vtjumpscroll ? 1 : 0);
-
- GetDItem(wcdial, WC_VTROWS, &type, &hitem, &rect);
- sprintf(&windtit[0], "%d", emdp->linecount);
- ctop(&windtit[0]);
- SetIText(hitem, &windtit[0]);
-
- GetDItem(wcdial, WC_VTCOLS, &type, &hitem, &rect);
- sprintf(&windtit[0], "%d", emdp->linelength);
- ctop(&windtit[0]);
- SetIText(hitem, &windtit[0]);
-
- /* ASCII things */
- escmap = emdp->escmap;
- ba_bs = emdp->ba_bs;
- crtonl = emdp->crtonl;
- emwrap = emdp->wrap_around;
- curseekmode = emdp->curseekmode;
- ibm_keymode = emdp->ibm_keymode;
- vtjumpscroll = emdp->vtjumpscroll;
-
- linecount = emdp->linecount;
- linelength = emdp->linelength;
-
- while (TRUE) {
- ModalDialog((ProcPtr) alfilter, &item_id);
- termindex = item_id - 3;
- switch (item_id) {
- case WC_OK: {
- if (ibm_keymode != emdp->ibm_keymode) {
- SetPort(emdp->emwindow);
- setibm_keymode(ibm_keymode);
- SetPort(wcdial);
- }
-
- /* update the settings */
- /* ASCII things */
- emdp->escmap = escmap;
- emdp->ba_bs = ba_bs;
- emdp->crtonl = crtonl;
- emdp->wrap_around = emwrap;
- emdp->ibm_keymode = ibm_keymode;
- emdp->vtjumpscroll = vtjumpscroll;
- emdp->curseekmode = curseekmode;
-
- wrap_around = emdp->wrap_around; /* update global */
-
- GetDItem(wcdial, WC_VTROWS, &type, &hitem, &rect);
- GetIText(hitem, &windtit[0]);
- ptoc(&windtit[0]);
- linecount = atoi(&windtit[0]);
-
- GetDItem(wcdial, WC_VTCOLS, &type, &hitem, &rect);
- GetIText(hitem, &windtit[0]);
- ptoc(&windtit[0]);
- linelength = atoi(&windtit[0]);
-
- if (linelength != emdp->linelength
- || linecount != emdp->linecount) {
- /* size of emulator has changed */
- if (linelength < 0 || linelength > 1000
- || linecount < 0 || linecount > 32) {
- error("Sorry, only emulator sizes up to 32 X 1000 are valid");
- }
- else {
- emdp->linecount = linecount;
- emdp->linelength = linelength;
-
- useqd(emdp); /* assume QD until next update since
- new size may be incompatible with useds() */
- termreset();
- setscreensize(emdp->fontsize);
- }
- }
- emdp->confchanged = TRUE;
-
- }
- case WC_CANCEL: {
- DisposDialog(wcdial);
- SetPort(oport);
- modaldialog = FALSE;
-
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
- if (item_id == WC_CANCEL)
- return(-1);
- return(0);
- }
- case WC_HELP: {
- helpwindow(TEXTEMDLOG, geneva, 9);
- buthilite(&okrect);
- break;
- }
- case WC_EM1: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- /* toggle IBM 7171/ASCII key mapping */
- ibm_keymode = !ibm_keymode;
- SetCtlValue(hitem, ibm_keymode ? 1 : 0);
- /* setibm_keymode will be called later on... */
-
- if (ibm_keymode) {
- /* hide all the purely ASCII-related controls,
- i.e., vi cursor mode */
- GetDItem(wcdial, WC_EM6, &type, &hitem, &rect);
- HideControl(hitem);
- GetDItem(wcdial, WC_EM7, &type, &hitem, &rect);
- HideControl(hitem);
- }
- else {
- /* show all the ASCII-related controls */
- GetDItem(wcdial, WC_EM6, &type, &hitem, &rect);
- ShowControl(hitem);
- GetDItem(wcdial, WC_EM7, &type, &hitem, &rect);
- ShowControl(hitem);
- }
- break;
- }
- case WC_EM2: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- escmap = !escmap;
- SetCtlValue(hitem, escmap ? 1 : 0);
- break;
- }
- case WC_EM3: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- ba_bs = !ba_bs;
- SetCtlValue(hitem, ba_bs ? 0 : 1);
- break;
- }
- case WC_EM4: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- crtonl = !crtonl;
- SetCtlValue(hitem, crtonl ? 1 : 0);
- break;
- }
- case WC_EM5: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- emwrap = !emwrap;
- SetCtlValue(hitem, emwrap ? 1 : 0);
- break;
- }
- case WC_EM6: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- curseekmode = !curseekmode;
- SetCtlValue(hitem, curseekmode ? 1 : 0);
- break;
- }
- case WC_EM7: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- /* toggle vt100 jump scroll mode */
- vtjumpscroll = !vtjumpscroll;
- SetCtlValue(hitem, vtjumpscroll ? 1 : 0);
- break;
- }
- default: {
- break;
- }
- }
- }
- }
-
- /* skip line for bar */
- #define WC_EM1 8
- #define WC_EM2 9
- #define WC_EM3 10
- #define WC_EM4 11
- #define WC_IBMMOD2 12
- #define WC_IBMMOD3 13
- #define WC_IBMMOD5 14
-
-
- /* configure emulator-specific session parameters; uses same basic fields
- as the setwindconf() dialog */
-
- set3270conf()
- {
- DialogPtr wcdial;
- short item_id;
- short type;
- Rect rect;
- Handle hitem;
- /* general purpose GetDItem vars */
- GrafPtr oport;
- short count;
- short termindex;
- char windtit[256]; /* temp for window title */
-
- /* IBM things */
- short typeahead;
- short nullsareblanks;
- short squeezeblanks;
- short shiftfield;
- short ibm_type;
-
- if (chkbackground())
- return(-1);
-
- GetPort(&oport);
- if ((wcdial = GetNewDialog(D3270CONFIG, (Ptr) NULL, (WindowPtr) (-1))) == NULL)
- return(-1);
-
- getcontext(keydp);
- emwdeactivate();
-
- SetPort(wcdial);
- centerwind(wcdial);
-
- SetCursor(&arrow);
- showcursor();
-
- modaldialog = TRUE;
-
- GetDItem(wcdial, WC_OK, &type, &hitem, &okrect);
- buthilite(&okrect);
- /* hilite "OK" key */
-
- GetDItem(wcdial, WC_SESSIONNAME, &type, &hitem, &rect);
- GetWTitle(emdp->emwindow, &windtit[0]);
- SetIText(hitem, &windtit[0]);
- /* put the session name in the window */
-
- GetDItem(wcdial, WC_EMTITLE, &type, &hitem, &rect);
-
- SetIText(hitem, "\P IBM 3278 emulator configuration");
-
- GetDItem(wcdial, WC_EM1, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Typeahead: allow input when System Busy");
- SetCtlValue(hitem, emdp->typeahead ? 1 : 0);
-
- GetDItem(wcdial, WC_EM2, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Send Imbedded 3278 Nulls as Blanks");
- SetCtlValue(hitem, emdp->nullsareblanks ? 1 : 0);
-
- GetDItem(wcdial, WC_EM3, &type, &hitem, &rect);
- SetCtlValue(hitem, emdp->squeezeblanks ? 1 : 0);
- SetCTitle(hitem, "\P Squeeze out blanks at end of field in Insert mode");
-
- GetDItem(wcdial, WC_EM4, &type, &hitem, &rect);
- SetCTitle(hitem, "\P Shift whole field when deleting characters");
- SetCtlValue(hitem, emdp->shiftfield ? 1 : 0);
-
- ibmtypebutset(wcdial, emdp->ibm_type + WC_IBMMOD2);
-
- /* IBM things */
- typeahead = emdp->typeahead;
- nullsareblanks = emdp->nullsareblanks;
- squeezeblanks = emdp->squeezeblanks;
- shiftfield = emdp->shiftfield;
- ibm_type = emdp->ibm_type;
-
- while (TRUE) {
- ModalDialog((ProcPtr) alfilter, &item_id);
- termindex = item_id - 3;
- switch (item_id) {
- case WC_OK: {
-
- /* update the settings */
- /* IBM things */
- emdp->typeahead = typeahead;
- emdp->nullsareblanks = nullsareblanks;
- emdp->squeezeblanks = squeezeblanks;
- emdp->shiftfield = shiftfield;
-
- if (emdp->ibm_type != ibm_type)
- error("IBM terminal type changes will take effect the next time you open the session document");
- emdp->ibm_type = ibm_type;
-
- emdp->confchanged = TRUE;
-
- }
- case WC_CANCEL: {
- DisposDialog(wcdial);
- SetPort(oport);
- modaldialog = FALSE;
-
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
- if (item_id == WC_CANCEL)
- return(-1);
- return(0);
- }
- case WC_HELP: {
- helpwindow(TEXT3270DLOG, geneva, 9);
- buthilite(&okrect);
- break;
- }
- case WC_EM1: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- typeahead = !typeahead;
- SetCtlValue(hitem, typeahead ? 1 : 0);
- break;
- }
- case WC_EM2: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- nullsareblanks = !nullsareblanks;
- SetCtlValue(hitem, nullsareblanks ? 1 : 0);
- break;
- }
- case WC_EM3: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- squeezeblanks = !squeezeblanks;
- SetCtlValue(hitem, squeezeblanks ? 1 : 0);
- break;
- }
- case WC_EM4: {
- GetDItem(wcdial, item_id, &type, &hitem, &rect);
- shiftfield = !shiftfield;
- SetCtlValue(hitem, shiftfield ? 1 : 0);
- break;
- }
- case WC_IBMMOD2:
- case WC_IBMMOD3:
- case WC_IBMMOD5:
- {
- ibm_type = item_id - WC_IBMMOD2;
- ibmtypebutset(wcdial, item_id);
- break;
- }
- default: {
- break;
- }
- }
- }
- }
-
- /* set the button selected and reset the others */
-
- ibmtypebutset(dlog, itemid)
- DialogPtr dlog;
- short itemid;
- {
- short type;
- Rect rect;
- Handle hitem;
-
- GetDItem(dlog, WC_IBMMOD2, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == WC_IBMMOD2 ? 1 : 0);
- GetDItem(dlog, WC_IBMMOD3, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == WC_IBMMOD3 ? 1 : 0);
- GetDItem(dlog, WC_IBMMOD5, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == WC_IBMMOD5 ? 1 : 0);
- }
-
-
- /* perform a dialog to do Global Configuration */
-
- #define GC_OK 1
- #define GC_CANCEL 2
- #define GC_TITLE 3 /* 12 types are allocated in the dialog */
- #define GC_HELP 4 /* type #s must correspond to this list */
- #define GC_SAVE 5
-
- #define GC_TRYDSDRAW 6
- #define GC_RISKYDSDRAW 7
- #define GC_MTCPSENDASYNC 8
- #define GC_EDRESETSELECT 9
- #define GC_QUITONCLOSE 10
- #define GC_TFTPSERVE 11
- #define GC_TFTPASK 12
- #define GC_COURIER 13
-
-
- setglobalconf()
- {
- DialogPtr gcdial;
- short item_id;
- short type;
- Rect rect;
- Handle hitem;
- /* general purpose GetDItem vars */
- GrafPtr oport;
- short count;
- short termindex;
-
- /* vars we work on */
- short otrydsdraw;
- short oquitonclose;
- short otftpserve;
- short otftpask;
- short ocourierprint;
- short oriskydsdraw;
- short omtcpsendasync;
- short oedresetselect;
-
- if (chkbackground())
- return(-1);
-
- GetPort(&oport);
- if ((gcdial = GetNewDialog(DGLOBALCONFIG, (Ptr) NULL, (WindowPtr) (-1))) == NULL)
- return(-1);
-
- getcontext(keydp);
- emwdeactivate();
-
- centerwind(gcdial);
-
- SetCursor(&arrow);
- showcursor();
-
- SetPort(gcdial);
- modaldialog = TRUE;
-
- GetDItem(gcdial, GC_OK, &type, &hitem, &okrect);
- buthilite(&okrect);
- /* hilite "OK" key */
-
- GetDItem(gcdial, GC_TRYDSDRAW, &type, &hitem, &rect);
- SetCtlValue(hitem, trydsdraw ? 1 : 0);
-
- GetDItem(gcdial, GC_RISKYDSDRAW, &type, &hitem, &rect);
- SetCtlValue(hitem, riskydsdraw ? 0 : 1); /* sense is "restrict drawing" */
-
- GetDItem(gcdial, GC_MTCPSENDASYNC, &type, &hitem, &rect);
- SetCtlValue(hitem, mtcpsendasync ? 1 : 0);
-
- GetDItem(gcdial, GC_EDRESETSELECT, &type, &hitem, &rect);
- SetCtlValue(hitem, edresetselect ? 1 : 0);
-
- GetDItem(gcdial, GC_QUITONCLOSE, &type, &hitem, &rect);
- SetCtlValue(hitem, quitonclose ? 1 : 0);
-
- GetDItem(gcdial, GC_TFTPSERVE, &type, &hitem, &rect);
- SetCtlValue(hitem, tftpserve == TFYES ? 1 : 0);
-
- GetDItem(gcdial, GC_TFTPASK, &type, &hitem, &rect);
- SetCtlValue(hitem, tftpask == TFYES ? 1 : 0);
-
- GetDItem(gcdial, GC_COURIER, &type, &hitem, &rect);
- SetCtlValue(hitem, courierprint ? 1 : 0);
-
- /* get current settings: note that 'o' prefix means *new*, whups! */
- otrydsdraw = trydsdraw;
- oquitonclose = quitonclose;
- oriskydsdraw = riskydsdraw;
- omtcpsendasync = mtcpsendasync;
- oedresetselect = edresetselect;
- otftpserve = tftpserve;
- otftpask = tftpask;
- ocourierprint = courierprint;
-
- while (TRUE) {
- ModalDialog((ProcPtr) alfilter, &item_id);
- switch (item_id) {
- case GC_CANCEL: {
- /* restore the old settings */
- DisposDialog(gcdial);
- SetPort(oport);
- modaldialog = FALSE;
-
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
- return(-1);
- }
- case GC_OK: {
- trydsdraw = otrydsdraw;
- quitonclose = oquitonclose;
- tftpserve = otftpserve;
- tftpask = otftpask;
- riskydsdraw = oriskydsdraw;
- mtcpsendasync = omtcpsendasync;
- edresetselect = oedresetselect;
- courierprint = ocourierprint;
-
- DisposDialog(gcdial);
- SetPort(oport);
- modaldialog = FALSE;
- if (tftpserve == TFYES)
- tfs_on();
- else
- tfs_off();
-
- if (keydp != NULL)
- InvalRect(&keydp->bigrect);
-
- if (trydsdraw != otrydsdraw) {
- testdsall();
- }
-
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
- return(0);
- }
- case GC_SAVE: {
- /* update the globals for saveglobalconfig() */
- trydsdraw = otrydsdraw;
- quitonclose = oquitonclose;
- tftpserve = otftpserve;
- tftpask = otftpask;
- riskydsdraw = oriskydsdraw;
- mtcpsendasync = omtcpsendasync;
- edresetselect = oedresetselect;
- courierprint = ocourierprint;
-
- if (saveglobalconfig())
- error("Save failed"); /* save it in the Comet settings file */
-
- break;
- }
- case GC_HELP: {
- helpwindow(TEXTGLOBALDLOG, geneva, 9);
- buthilite(&okrect);
- break;
- }
- case GC_TRYDSDRAW: {
- otrydsdraw = !otrydsdraw;
- GetDItem(gcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, otrydsdraw ? 1 : 0);
- break;
- }
- case GC_QUITONCLOSE: {
- oquitonclose = !oquitonclose;
- GetDItem(gcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, oquitonclose ? 1 : 0);
- break;
- }
- case GC_COURIER: {
- ocourierprint = !ocourierprint;
- GetDItem(gcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, ocourierprint ? 1 : 0);
- break;
- }
- case GC_TFTPSERVE: {
- if (otftpserve == TFYES)
- otftpserve = TFNO;
- else
- otftpserve = TFYES;
- GetDItem(gcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, otftpserve == TFYES ? 1 : 0);
- break;
- }
- case GC_TFTPASK: {
- if (otftpask == TFYES)
- otftpask = TFNO;
- else
- otftpask = TFYES;
- GetDItem(gcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, otftpask == TFYES ? 1 : 0);
- break;
- }
- case GC_RISKYDSDRAW: {
- oriskydsdraw = !oriskydsdraw;
- GetDItem(gcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, oriskydsdraw ? 0 : 1);
- break;
- }
- case GC_MTCPSENDASYNC: {
- omtcpsendasync = !omtcpsendasync;
- GetDItem(gcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, omtcpsendasync ? 1 : 0);
- break;
- }
- case GC_EDRESETSELECT: {
- oedresetselect = !oedresetselect;
- GetDItem(gcdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, oedresetselect ? 1 : 0);
- break;
- }
- default: {
- break;
- }
- }
- }
- }
-
-
-
- queryclosewind(twp)
- struct winds * twp;
- {
- if (twp == emdp)
- savecontext(emdp);
- else
- getcontext(twp);
-
- if (twp->connopen) {
- error("Sorry, you must close the window's session first");
- return(-1);
- }
- if (queryconfchange(twp))
- return(-1);
-
- /* save the window position */
- reopenconfig(twp);
- saveonewindpos(twp);
- closeconfig(twp);
-
- /* TODO must release all terminal memory */
- killwind(twp);
- releaseconfig();
- releaseconn(twp);
-
- return(0);
- }
-
-
- /* ask the user whether the configuration should be saved */
-
- queryconfchange(twp)
- struct winds * twp;
- {
- short item;
- DialogPtr dptr;
- GrafPtr oport;
- short type;
- Rect rect;
- Handle hitem;
- /* general purpose GetDItem vars */
-
- if (twp->confchanged) {
- /* give user the option of saving the configuration */
- if (!twp->backonly) {
- GetPort(&oport);
- chkbackground();
- HLock(twp->hhostname);
- ParamText(*twp->hhostname, "\P", "\P", "\P");
- HUnlock(twp->hhostname);
- if ( (dptr = GetNewDialog(SAVEDIALOG, (Ptr) NULL, (WindowPtr) -1))
- != NULL) {
-
- emwdeactivate();
- SetPort(dptr);
- centerwind(dptr);
-
- /* hilite "Save" key */
- GetDItem(dptr, SD_SAVE, &type, &hitem, &rect);
- buthilite(&rect);
-
- modaldialog = TRUE;
- do {
- ModalDialog( (ProcPtr) alfilter, &item);
- }
- while (item == 0);
-
- DisposDialog(dptr);
- SetPort(oport);
- modaldialog = FALSE;
- if (item == SD_CANCEL) {
- /* cancel whatever procedure called us */
- return(-1);
- }
- else if (item == SD_SAVE) {
- getcontext(twp);
- if (optkeydown()) {
- namewindow();
- }
- saveconfig(emdp, creator);
- }
- else if (item == SD_DONT) {
- twp->confchanged = FALSE;
- }
- }
- }
- }
- /* we arrive here if we didn't care to save, too */
- return(0);
- }
-
-
- querycloseconn(twp)
- struct winds * twp;
- {
- short item;
- DialogPtr dptr;
- GrafPtr oport;
- short type;
- Rect rect;
- Handle hitem;
-
- if (!mfbackonly && twp->connopen) {
- /* some connection has been attempted, get user's OK */
- GetPort(&oport);
- chkbackground();
- HLock(twp->hhostname);
- ParamText(*twp->hhostname, "\P", "\P", "\P");
- HUnlock(twp->hhostname);
- if ( (dptr = GetNewDialog(QUITDIALOG, (Ptr) NULL, (WindowPtr) -1))
- != NULL) {
-
- emwdeactivate();
- SetPort(dptr);
- centerwind(dptr);
-
- /* hilite "OK" key */
- GetDItem(dptr, QUITOK, &type, &hitem, &rect);
- buthilite(&rect);
-
- modaldialog = TRUE;
- do {
- ModalDialog( (ProcPtr) alfilter, &item);
- }
- while (item == 0);
-
- DisposDialog(dptr);
- SetPort(oport);
- modaldialog = FALSE;
- if (item == QUITCANCEL) {
- return(TRUE);
- }
- }
- /* go ahead and close up the connections... */
- }
- return(FALSE);
- }
-
-
- /* if the configuration file has not been saved, prompt the user to do so */
-
- querynewconf()
- {
- if (keydp->newconf) {
- error("You need to save this new document before defining macros");
- getcontext(keydp);
- if (optkeydown()) {
- namewindow();
- }
- saveconfig(keydp, creator);
- if (keydp->newconf)
- /* it's still not open */
- return(TRUE);
- }
- return(FALSE);
- }
-
-
-
- /* perform a dialog to set the key pad */
-
- #define KD_OK 1
- #define KD_CANCEL 2
- #define KD_PICBOX 3
- #define KD_NORMKEY 4
- #define KD_KEYPAD1 5
- #define KD_KEYPAD2 6
- #define KD_KEYPAD3 7
- #define KD_KEYPAD4 8
-
- #define KD_SWITCHKEY 9
- #define KD_SESSIONNAME 10
-
- setibmkeypad()
- {
- DialogPtr kpdial;
- int item_id;
- int type;
- Rect rect;
- Rect picrect;
- Handle hitem;
- /* general purpose GetDItem vars */
- GrafPtr oport;
- short okeypad;
- short okeypadswitch;
- int count;
- PicHandle keypic[4];
- char windtit[256]; /* temp for window title */
-
- GetPort(&oport);
-
- if (chkbackground())
- return(0);
-
- if ((kpdial = GetNewDialog(DSETKEYPAD, (Ptr) NULL, (WindowPtr) (-1))) == NULL)
- return(0);
-
- getcontext(keydp);
- emwdeactivate();
-
- centerwind(kpdial);
-
- SetCursor(&arrow);
- showcursor();
- SetPort(kpdial);
-
- modaldialog = TRUE;
-
- okeypad = keydp->keypad;
- okeypadswitch = keypadswitch;
-
- GetDItem(kpdial, KD_OK, &type, &hitem, &rect);
- buthilite(&rect);
- /* hilite "OK" key */
-
- GetDItem(kpdial, KD_SESSIONNAME, &type, &hitem, &rect);
- GetWTitle(emdp->emwindow, &windtit[0]);
- SetIText(hitem, &windtit[0]);
- /* put the session name in the window */
-
- for (count = 0; count < NUMKEYPICS; count++)
- keypic[count] = (PicHandle) GetResource('PICT', PICKEYP1 + count);
-
- /* highlight current selection and display */
- GetDItem(kpdial, KD_PICBOX, &type, &hitem, &picrect);
- kpdialbutset(kpdial, keydp->keypad + KD_NORMKEY);
- DrawPicture(keypic[keydp->keypad], &picrect);
-
- /* set keypadswitch check box */
- GetDItem(kpdial, KD_SWITCHKEY, &type, &hitem, &rect);
- SetCtlValue(hitem, keypadswitch ? 1 : 0);
-
- while (TRUE) {
- ModalDialog((ProcPtr) alfilter, &item_id);
- switch (item_id) {
- case KD_CANCEL:
- keydp->keypad = okeypad;
- keypadswitch = okeypadswitch;
- case KD_OK: {
- pfmenuhack(keydp);
-
- if (keypadswitch != okeypadswitch && saveglobalconfig())
- error(keyswerr); /* save it in the Comet settings file */
-
- DisposDialog(kpdial);
- SetPort(oport);
- modaldialog = FALSE;
-
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
- if (item_id == KD_CANCEL)
- return(0);
- else
- return(TRUE);
- }
- case KD_NORMKEY: {
- keydp->keypad = NORMKEYPAD;
- kpdialbutset(kpdial, item_id);
- DrawPicture(keypic[keydp->keypad], &picrect);
- break;
- }
- case KD_KEYPAD1: {
- keydp->keypad = KEYPAD1;
- kpdialbutset(kpdial, item_id);
- DrawPicture(keypic[keydp->keypad], &picrect);
- break;
- }
- case KD_KEYPAD2: {
- keydp->keypad = KEYPAD2;
- kpdialbutset(kpdial, item_id);
- DrawPicture(keypic[keydp->keypad], &picrect);
- break;
- }
- case KD_KEYPAD3: {
- keydp->keypad = KEYPAD3;
- kpdialbutset(kpdial, item_id);
- DrawPicture(keypic[keydp->keypad], &picrect);
- break;
- }
- case KD_SWITCHKEY: {
- keypadswitch = !keypadswitch;
- GetDItem(kpdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, keypadswitch ? 1 : 0);
- break;
- }
- default: {
- break;
- }
- }
- }
- }
-
-
- /* set the button selected and reset the others */
-
- kpdialbutset(dlog, itemid)
- DialogPtr dlog;
- short itemid;
- {
- short type;
- Rect rect;
- Handle hitem;
-
- GetDItem(dlog, KD_NORMKEY, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == KD_NORMKEY ? 1 : 0);
- GetDItem(dlog, KD_KEYPAD1, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == KD_KEYPAD1 ? 1 : 0);
- GetDItem(dlog, KD_KEYPAD2, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == KD_KEYPAD2 ? 1 : 0);
- GetDItem(dlog, KD_KEYPAD3, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == KD_KEYPAD3 ? 1 : 0);
- }
-
-
- /* perform a dialog to set the VT100 key pad */
-
- setvtkeypad()
- {
- DialogPtr kpdial;
- int item_id;
- int type;
- Rect rect;
- Rect picrect;
- Handle hitem;
- /* general purpose GetDItem vars */
- GrafPtr oport;
- short nvtkeypad;
- short nvtaltcursor;
- short nvtaltkeypad;
- short okeypadswitch;
-
- int count;
- PicHandle keypic[4];
- char windtit[256]; /* temp for window title */
-
- GetPort(&oport);
-
- if (chkbackground())
- return(0);
-
- if ((kpdial = GetNewDialog(DVTSETKEYPAD, (Ptr) NULL, (WindowPtr) (-1))) == NULL)
- return(0);
-
- getcontext(keydp);
- emwdeactivate();
-
- centerwind(kpdial);
-
- SetCursor(&arrow);
- showcursor();
- SetPort(kpdial);
-
- modaldialog = TRUE;
-
- nvtkeypad = keydp->vtkeypad;
- nvtaltkeypad = keydp->vtaltkeypad;
- nvtaltcursor = keydp->vtaltcursor;
- okeypadswitch = keypadswitch;
-
- GetDItem(kpdial, KD_OK, &type, &hitem, &rect);
- buthilite(&rect);
- /* hilite "OK" key */
-
- GetDItem(kpdial, KD_SESSIONNAME, &type, &hitem, &rect);
- GetWTitle(emdp->emwindow, &windtit[0]);
- SetIText(hitem, &windtit[0]);
- /* put the session name in the window */
-
- for (count = 0; count < NUMVTKEYPICS; count++)
- keypic[count] = (PicHandle) GetResource('PICT', VTPICKEYP1 + count);
-
- /* highlight current selection and display */
- GetDItem(kpdial, KD_PICBOX, &type, &hitem, &picrect);
- vtkpbutset(kpdial, keydp->vtkeypad + KD_NORMKEY);
-
- if (keydp->vtkeypad) {
- DrawPicture(keypic[keydp->vtkeypad - 1], &picrect);
- }
- else {
- /* automatic mode, set pic according to current settings */
- if (!keydp->vtaltkeypad) {
- DrawPicture(keypic[KD_KEYPAD1 - 5], &picrect);
- }
- else {
- if (keydp->vtaltcursor == 'O')
- DrawPicture(keypic[KD_KEYPAD2 - 5], &picrect);
- else
- DrawPicture(keypic[KD_KEYPAD3 - 5], &picrect);
- }
- }
-
- /* set keypadswitch check box */
- GetDItem(kpdial, KD_SWITCHKEY, &type, &hitem, &rect);
- SetCtlValue(hitem, keypadswitch ? 1 : 0);
-
- while (TRUE) {
- ModalDialog((ProcPtr) alfilter, &item_id);
- switch (item_id) {
- case KD_OK: {
- keydp->vtkeypad = nvtkeypad;
- keydp->vtaltkeypad = nvtaltkeypad;
- keydp->vtaltcursor = nvtaltcursor;
- keypadswitch = okeypadswitch;
- /* fall through */
- case KD_CANCEL:
- if (keypadswitch != okeypadswitch && saveglobalconfig())
- error(keyswerr); /* save it in the Comet settings file */
-
- DisposDialog(kpdial);
- SetPort(oport);
- modaldialog = FALSE;
-
- okrect.top = okrect.left = okrect.bottom = okrect.right = 0;
- if (item_id == KD_CANCEL)
- return(0);
- else
- return(TRUE);
- }
- case KD_NORMKEY: {
- nvtkeypad = 0;
- vtkpbutset(kpdial, item_id);
- /* automatic mode, set pic according to current settings */
- if (!keydp->vtaltkeypad) {
- DrawPicture(keypic[KD_KEYPAD1 - 5], &picrect);
- }
- else {
- if (keydp->vtaltcursor == 'O')
- DrawPicture(keypic[KD_KEYPAD2 - 5], &picrect);
- else
- DrawPicture(keypic[KD_KEYPAD3 - 5], &picrect);
- }
- break;
- }
- case KD_KEYPAD1: {
- /* calculator keypad */
- nvtkeypad = KEYPAD1;
- nvtaltkeypad = FALSE;
- vtkpbutset(kpdial, item_id);
- DrawPicture(keypic[nvtkeypad - 1], &picrect);
- break;
- }
- case KD_KEYPAD2: {
- /* application */
- nvtkeypad = KEYPAD2;
- nvtaltkeypad = TRUE;
- nvtaltcursor = 'O';
- vtkpbutset(kpdial, item_id);
- DrawPicture(keypic[nvtkeypad - 1], &picrect);
- break;
- }
- case KD_KEYPAD3: {
- /* application alternate cursor mode */
- nvtkeypad = KEYPAD3;
- nvtaltcursor = '[';
- vtkpbutset(kpdial, item_id);
- DrawPicture(keypic[nvtkeypad - 1], &picrect);
- break;
- }
- case KD_SWITCHKEY: {
- okeypadswitch = !okeypadswitch;
- GetDItem(kpdial, item_id, &type, &hitem, &rect);
- SetCtlValue(hitem, okeypadswitch ? 1 : 0);
- break;
- }
- default: {
- break;
- }
- }
- }
- }
-
-
- /* set the button selected and reset the others */
-
- vtkpbutset(dlog, itemid)
- DialogPtr dlog;
- short itemid;
- {
- short type;
- Rect rect;
- Handle hitem;
-
- GetDItem(dlog, KD_NORMKEY, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == KD_NORMKEY ? 1 : 0);
- GetDItem(dlog, KD_KEYPAD1, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == KD_KEYPAD1 ? 1 : 0);
- GetDItem(dlog, KD_KEYPAD2, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == KD_KEYPAD2 ? 1 : 0);
- GetDItem(dlog, KD_KEYPAD3, &type, &hitem, &rect);
- SetCtlValue(hitem, itemid == KD_KEYPAD3 ? 1 : 0);
- }
-
-
- radbuthilite(rectp, state)
- Rect * rectp;
- int state;
- {
- rectp->top += 5;
- rectp->bottom -= 5;
- rectp->left += 5;
- rectp->right = rectp->left + (rectp->bottom - rectp->top);
- /* we're just assuming the button position from the
- control top/left/bottom position */
- FillOval(rectp, state ? black : white);
- }
-
-
- #define DTEXTTITLE 3
- #define DTEXTSTRING 4
-
- /* get a string of text from the user */
-
- querytext(title, dest)
- char * title;
- unsigned char * dest;
- {
- short item;
- DialogPtr dptr;
- GrafPtr oport;
- short type;
- Rect rect;
- Handle hitem;
-
- /* some connection has been attempted, get user's OK */
- GetPort(&oport);
- chkbackground();
-
- if ( (dptr = GetNewDialog(DGETTEXT, (Ptr) NULL, (WindowPtr) -1)) == NULL) {
- return;
- }
-
- emwdeactivate();
- SetPort(dptr);
- centerwind(dptr);
-
- ctop(title);
- GetDItem(dptr, DTEXTTITLE, &type, &hitem, &rect);
- SetIText(hitem, title);
- ptoc(title);
-
- if (*dest != '\000') {
- /* if there was a find already performed use the previous string */
- ctop(dest);
- GetDItem(dptr, DTEXTSTRING, &type, &hitem, &rect);
- SetIText(hitem, dest);
- SelIText(dptr, DTEXTSTRING, 0, 1000);
- ptoc(dest);
- }
- /* hilite "OK" key */
- GetDItem(dptr, OKB, &type, &hitem, &rect);
- buthilite(&rect);
-
- TEFromScrap();
-
- modaldialog = TRUE;
- do {
- ModalDialog( (ProcPtr) alfilter, &item);
- }
- while (! (item == OKB || item == CANB));
-
- modaldialog = FALSE;
- ZeroScrap();
- TEToScrap();
- /* copy the TE scrap to the Scrap */
-
- if (item == CANB) {
- DisposDialog(dptr);
- SetPort(oport);
- return(TRUE);
- }
- /* set the string array to the string the user entered... */
- GetDItem(dptr, DTEXTSTRING, &type, &hitem, &rect);
- GetIText(hitem, dest);
- ptoc(dest);
-
- DisposDialog(dptr);
- SetPort(oport);
- return(FALSE);
- }
-
- /* ask the user whether an open serial session should be closed automatically
- when a new one is opened; returns TRUE if close desired */
-
- queryserclose(twp)
- struct winds * twp;
- {
- short item;
- DialogPtr dptr;
- GrafPtr oport;
- short type;
- Rect rect;
- Handle hitem;
-
- /* some connection has been attempted, get user's OK */
- GetPort(&oport);
- chkbackground();
- HLock(twp->hhostname);
- ParamText(*twp->hhostname, "\P", "\P", "\P");
- HUnlock(twp->hhostname);
- if ( (dptr = GetNewDialog(DSERCLOSE, (Ptr) NULL, (WindowPtr) -1))
- != NULL) {
-
- emwdeactivate();
- SetPort(dptr);
- centerwind(dptr);
-
- /* hilite "OK" key */
- GetDItem(dptr, QUITOK, &type, &hitem, &rect);
- buthilite(&rect);
-
- modaldialog = TRUE;
- do {
- ModalDialog( (ProcPtr) alfilter, &item);
- }
- while (item == 0);
-
- DisposDialog(dptr);
- SetPort(oport);
- modaldialog = FALSE;
- if (item == QUITCANCEL) {
- return(FALSE);
- }
- }
- return(TRUE);
- }